package com.es.www.kyl.controller.web;

import com.es.www.kyl.bean.req.LoginReq;
import com.es.www.kyl.bean.res.LoginRes;
import com.es.www.kyl.service.LoginService;
import com.es.www.kyl.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.es.www.kyl.bean.R;

/**
 * @Author by michangtao
 * @Date 2023/3/14 16:43
 * @Description
 */
@Api(tags = "后台-登录模块")
@RequiredArgsConstructor
@RestController
@RequestMapping("/web/login")
public class WebLoginController {

    private final LoginService loginService;
    private final SmsService smsService;

    @ApiOperation("获取图形验证码")
    @PostMapping("/getVerifyCode")
    public R<String> getVerifyCode(@RequestParam String phone) {
        return R.successResponse(smsService.getVerifyCode(phone));
    }


    /**
     * web端登录
     * @return
     */
    @ApiOperation("web端登录")
    @PostMapping("/webLogin")
    public R<LoginRes> webLogin(@RequestBody @Validated LoginReq loginReq) {
        return R.successResponse(loginService.webLogin(loginReq));
    }








}
